package com.gwkj.zxjl_user.Utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.telephony.TelephonyManager;

import com.gwkj.zxjl_user.Constants.PLATFORM;


/**
 * 设备信息
 * Created by FuJiahui on 2016/6/26.
 */
public class DeviceUtils {

    //获取设备ID
    public static String getDevice_id(Context context){
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return  tm.getDeviceId();
    }

    //获取设备信息
    public static String getDevice_info(){
        return Build.MODEL;
    }

    //获取版本号
    public static String getVersionName(Context context) {
        try {
            PackageInfo pi=context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
            return pi.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return "";
        }
    }
    //获取版本号(内部识别号)
    public static int getVersionCode(Context context) {
        try {
            PackageInfo pi=context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
            return pi.versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return 0;
        }
    }

    public static String getPlatform(){
        return PLATFORM.PLANT;
    }

    public static String getApp(){
        return PLATFORM.APP;
    }

}
